import crypto from 'crypto';

/* 加密用户名，密码 */
export function encode(str) {
  const cipher = crypto.createCipher('aes192', 'deliveryIsen');
  let crypted = cipher.update(str, 'utf8', 'hex');
  crypted += cipher.final('hex');
  return crypted;
}

export function set(key, value) {
  localStorage.setItem(key, JSON.stringify(value));
}

export function get(key) {
  const val = localStorage.getItem(key);
  try {
    return JSON.parse(val);
  } catch (error) {
    return val;
  }
}
